/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.amit.util;

import java.util.Date;

/**
 *
 * @author amit
 */
public class DateUtils {

    /**
     * All minutes have this many milliseconds except the last minute of the day on a day defined with
     * a leap second.
     */
    public static final long MILLISECS_PER_MINUTE = 60 * 1000;
    /**
     * Number of milliseconds per hour, except when a leap second is inserted.
     */
    public static final long MILLISECS_PER_HOUR = 60 * MILLISECS_PER_MINUTE;
    protected static final long MILLISECS_PER_DAY = 24 * MILLISECS_PER_HOUR;

    public static void main(String[] args) {
        Date from = new Date("05/11/10");
        System.out.println(from.getYear());
        Date to = new Date("05/18/2010");
        System.out.println(numDaysBetween(from, to));
    }

    public static long numDaysBetween(Date from, Date to) {
        long diff = to.getTime() - from.getTime();
        return diff / MILLISECS_PER_DAY;
    }
}
